package com.xjoyt.pay.master.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

import com.xjoyt.pay.abstracts.AbstractDao;
import com.xjoyt.pay.master.dao.CompanyRateRepositoryCustom;
import com.xjoyt.pay.master.po.CompanyRate;
import com.xjoyt.pay.master.repository.CompanyRateRepository;
import com.xjoyt.pay.vo.PayType;

public class CompanyRateRepositoryImpl extends AbstractDao implements CompanyRateRepositoryCustom {

	@Autowired
	private CompanyRateRepository repository;

	@Override
	public CompanyRate findOneByCompanyIdAndType(String companyId, PayType type) {
		Page<CompanyRate> page = repository.findAllByCompanyIdAndType(companyId, type, getFirstPageable());
		return page.hasContent() ? page.iterator().next() : null;
	}

}
